

def testBase(a1, a2, a3):
    print('testBase', a1, a2, a3)
    return 0

def testStl(a1, a2, a3):
    print('testStl', a1, a2, a3)
    return True

def test_returnStl():
    print('test_returnStl')
    #map<string, list<vector<int> > >
    ret = {'Oh':[[111,222], [333, 444] ] }
    return ret

def testRegFunction():
    import ffpython
    ffpython.printVal(123, 45.6 , "----789---", [3.14])
    ret = ffpython.returnStl()
    print('testRegFunction', ret)

def testRegisterBaseClass():
    import ffpython
    foo = ffpython.Foo(20130426)
    
    print("testRegisterBaseClass get_val:", foo.getValue())
    foo.setValue(778899)
    print("testRegisterBaseClass get_val:", foo.getValue(), foo.nValue)
    foo.testStl({"key": [11,22,33] })
    print('testRegisterBaseClass testRegisterBaseClass', foo)

def testRegisterInheritClass():
    import ffpython
    dumy = ffpython.Dumy(20130426)
    print(ffpython.Dumy._AllFields)
    print("testRegisterInheritClass get_val:", dumy.getValue())
    dumy.setValue(778899)
    print("testRegisterInheritClass get_val:", dumy.getValue(), dumy.nValue)
    dumy.testStl({"key": [11,22,33] })
    dumy.dump()
    print('testRegisterInheritClass', dumy)

def testCppObjToPy_ext(foo):
    print('testCppObjToPy_ext', len(foo))
    for k in range(0, len(foo)):
        print('testCppObjToPy_ext', k, foo[k].nValue)
    
def testCppObjToPy(foo):
    import ffpython
    print("testCppObjToPy get_val:", foo.getValue())
    foo.setValue(778899)
    print("testCppObjToPy get_val:", foo.getValue(), foo.nValue)
    foo.testStl({"key": [11,22,33] })
    foo.nValue = 100
    print('testCppObjToPy testRegisterBaseClass', foo)

def testCppObjToPy2(dumyList):
    dumy = dumyList[0]
    import ffpython
    print("testCppObjToPy get_val:", dumy.getValue())
    dumy.setValue(778899)
    print("testCppObjToPy get_val:", dumy.getValue(), dumy.nValue)
    dumy.testStl({"key": [11,22,33] })
    dumy.dump()
    ffpython.objTest(dumy)
    print('testCppObjToPy', dumy)
    
    return dumy

class PyClass:
    def __init__(self):
        print('PyClass init....')
    def sayHi(self, a1, a2):
        print('sayHi..', a1, a2)
def testCppObjReturnPyObj():
    import ffpython
    return PyClass()
def testCppObjReturnPyLambda():
    def testLambda(a1):
        print('testLambda....', a1)
    return testLambda
print(__name__+" load ok")

def testmain2(a = 0):
    import ffext
    #print(ffext._ALL_CLASS_DEF_CODE)
    b = ffext.AddNum(1, 2)
    print('testmain a:%d,b=%g'%(a, b))
    pos = ffext.Pos(5, 6)
    #pos.x = 50
    if 1:
        print(pos, pos.x, pos.y)
        print(ffext.Pos._AllFields)
        print(ffext.Animal._AllFields)
        animal = ffext.Bird('abcd', 112233)
        animal.SetName('ABCD')
        print(animal, ffext.Animal.PrintTypeName(), animal.GetName())
        animal.Go(pos)
        del animal
        #print(animal.GetPos())
    print('pos', pos, repr(pos))

    print('pos delete trace begin')
    #pos._delete()
    print('pos', pos, repr(pos))
    print('pos delete trace end')
    f = ffext.TestLambda(100, lambda x: x * 10)
    rf = f(10)
    print('TestLambda', rf)
    posSharedPtr = ffext.GenPos(55, 66)
    print(posSharedPtr)
    print(ffext.ForkPos(posSharedPtr))
    del posSharedPtr
    print('posSharedPtr end')
    
def testmain(a = 0):
    testmain2(a)
    print('testmain end!!')
    return 1